package com.zhenmyan.secdeal.controller;

import com.zhenmyan.secdeal.rabbitmq.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * description:
 *
 * @author 颜真明
 * @date 2023/5/15  5:46
 */
@RestController
@RequestMapping("/mq")
public class MQTestController {

    @Resource
    private MQSender mqSender;

    @Resource
    private MQFanoutSender mqFanoutSender;

    @Resource
    private MQDirectSender mqDirectSender;

    @Resource
    private MQTopicSender mqTopicSender;

    @Resource
    private MQHeadersSender mqHeadersSender;

    /**
     * 普通模式
     */
    @RequestMapping(value = "/normal", method = RequestMethod.GET)
    @ResponseBody
    public void mq() {
        System.out.println("启动normal模式：消息开始发送");
        mqSender.send("正常模式消息体");
    }

    /**
     * fanout模式
     */
    @RequestMapping(value = "/fanout", method = RequestMethod.GET)
    @ResponseBody
    public void fanout() {
        System.out.println("启动fanout模式：消息开始发送");
        mqFanoutSender.send("fanout模式消息体");
    }

    /**
     * fanout模式
     */
    @RequestMapping(value = "/direct", method = RequestMethod.GET)
    @ResponseBody
    public void direct() {
        System.out.println("启动direct模式：消息开始发送");
        mqDirectSender.send1("direct模式，路由键1消息体");
        mqDirectSender.send2("direct模式，路由键2消息体");
    }

    /**
     * topic模式
     */
    @RequestMapping(value = "/topic", method = RequestMethod.GET)
    @ResponseBody
    public void topic() {
        System.out.println("启动topic模式：消息开始发送");
        mqTopicSender.send1("topic模式，路由键1消息体");
        mqTopicSender.send2("topic模式，路由键2消息体");
    }

    /**
     * headers模式
     */
    @RequestMapping(value = "/headers", method = RequestMethod.GET)
    @ResponseBody
    public void headers() {
        System.out.println("启动headers模式：消息开始发送");
        mqHeadersSender.send1("headers模式，路由键1消息体");
        mqHeadersSender.send2("headers模式，路由键2消息体");
    }

}
